library(mgcv)
## Loading required package: nlme
## This is mgcv 1.8-31. For overview type 'help("mgcv-package")'.
library(ggplot2)
df <- read.csv("~/Desktop/medical records/combined.csv")
Data in general Static compliance range are set as 0-300 (may change. KC See says 100 is normal. ) high compliance: >40, low compliance: < 40 (may change)
ggplot(df,aes(x=pfratio,y=lung_compliance))+ geom_point(alpha = 0.1)
model1<-gam(lung_compliance ~ pfratio,data=df,method = "REML")
summary(model1)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## lung_compliance ~ pfratio
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 32.500866 0.562211 57.809 < 2e-16 ***
## pfratio 0.022612 0.002979 7.591 3.38e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.004 Deviance explained = 0.407%
## -REML = 64239 Scale est. = 529.91 n = 14101
ggplot(df, aes(x=pfratio,y=lung_compliance)) + geom_point(alpha = 0.1) + geom_smooth(method = "gam", formula = y ~s(x))
boxplot(df$lung_compliance[df$ARDS_severity=="mild"],
df$lung_compliance[df$ARDS_severity=="moderate"],
df$lung_compliance[df$ARDS_severity=="severe"],
names = c('mild ARDS','moderate ARDS','severe ARDS'),
ylab = 'Static Compliance')
# severe ARDS + severe (compliance < 40)
df2<-df[df$pfratio<=100 & df$lung_compliance<=40,]
model2<-gam(lung_compliance ~ pfratio,data=df2,method = "REML")
summary(model2)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## lung_compliance ~ pfratio
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 22.64991 0.99565 22.749 < 2e-16 ***
## pfratio 0.03602 0.01274 2.826 0.00477 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.00437 Deviance explained = 0.5%
## -REML = 5597.4 Scale est. = 66.029 n = 1592
ggplot(df2, aes(x=pfratio,y=lung_compliance)) + geom_point(alpha = 0.1) + geom_smooth(method = "gam", formula = y ~s(x))
# moderate ARDS + severe (compliance < 40)
df3<-df[df$pfratio<=200 & df$pfratio>100 & df$lung_compliance<=40,]
model3<-gam(lung_compliance ~ pfratio,data=df3,method = "REML")
summary(model3)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## lung_compliance ~ pfratio
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 24.189744 0.591697 40.882 < 2e-16 ***
## pfratio 0.017911 0.003804 4.708 2.57e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.00438 Deviance explained = 0.459%
## -REML = 16579 Scale est. = 57.354 n = 4813
ggplot(df3, aes(x=pfratio,y=lung_compliance)) + geom_point(alpha = 0.1) + geom_smooth(method = "gam", formula = y ~s(x))
# mild ARDS + severe (compliance < 40)
df4<-df[df$pfratio>200 & df$lung_compliance<=40,]
model4<-gam(lung_compliance ~ pfratio,data=df4,method = "REML")
summary(model4)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## lung_compliance ~ pfratio
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.426560 1.065874 28.546 < 2e-16 ***
## pfratio -0.011669 0.004313 -2.705 0.00686 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.00172 Deviance explained = 0.199%
## -REML = 12564 Scale est. = 54.031 n = 3679
ggplot(df4, aes(x=pfratio,y=lung_compliance)) + geom_point(alpha = 0.1) + geom_smooth(method = "gam", formula = y ~s(x))
# severe ARDS + severe (compliance > 40)
df5<-df[df$pfratio<=100 & df$lung_compliance>40,]
model5<-gam(lung_compliance ~ pfratio,data=df5,method = "REML")
summary(model5)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## lung_compliance ~ pfratio
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 67.73595 9.16026 7.395 7.62e-13 ***
## pfratio -0.07829 0.11244 -0.696 0.487
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = -0.00121 Deviance explained = 0.114%
## -REML = 2080 Scale est. = 1001.8 n = 427
ggplot(df5, aes(x=pfratio,y=lung_compliance)) + geom_point(alpha = 0.1) + geom_smooth(method = "gam", formula = y ~s(x))
# moderate ARDS + severe (compliance > 40)
df6<-df[df$pfratio<=200 &df$pfratio>100 & df$lung_compliance>40,]
model6<-gam(lung_compliance ~ pfratio,data=df6,method = "REML")
summary(model6)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## lung_compliance ~ pfratio
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 68.52038 3.59319 19.070 <2e-16 ***
## pfratio -0.05790 0.02313 -2.503 0.0124 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.0027 Deviance explained = 0.321%
## -REML = 9335.2 Scale est. = 858.36 n = 1946
ggplot(df6, aes(x=pfratio,y=lung_compliance)) + geom_point(alpha = 0.1) + geom_smooth(method = "gam", formula = y ~s(x))
# mild ARDS + severe (compliance > 40)
df7<-df[df$pfratio>200 & df$lung_compliance>40,]
model7<-gam(lung_compliance ~ pfratio,data=df7,method = "REML")
summary(model7)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## lung_compliance ~ pfratio
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 56.99230 6.46494 8.816 <2e-16 ***
## pfratio 0.01788 0.02600 0.688 0.492
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = -0.000321 Deviance explained = 0.0288%
## -REML = 7968.2 Scale est. = 948.09 n = 1644
ggplot(df7, aes(x=pfratio,y=lung_compliance)) + geom_point(alpha = 0.1) + geom_smooth(method = "gam", formula = y ~s(x))